//
//  SRSystem+Cate.m
//  SportRing
//
//  Created by mykoma on 14/11/1.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "SRSystem+Cate.h"

@implementation SRSystem (Cate)

+ (SRSystem *)system
{
    __block SRSystem * system = nil;
    [MagicalRecord saveUsingCurrentThreadContextWithBlockAndWait:^(NSManagedObjectContext *localContext)
     {
         system = [SRSystem MR_createEntity];
     }];
    return system;
}

- (void)configAttributesWithBlock:(void(^)(SRSystem * aSelf))block
{
    [MagicalRecord saveUsingCurrentThreadContextWithBlockAndWait:^(NSManagedObjectContext *localContext)
     {
         block(self);
     }];
}

@end


@implementation SRSystem (Find)

+ (SRSystem *)findDefaultSystem
{
    SRSystem * system = [SRSystem MR_findFirst];
    if (system == nil) {
        system = [SRSystem system];
    }
    return system;
}

@end